package com.block.datapush.service.apipush.utils;

import cn.hutool.core.util.StrUtil;
import com.block.common.enums.BaseTypeInfoEnum;
import org.apache.commons.lang3.StringUtils;

import javax.crypto.Cipher;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;

/**
 * 信用派 双授权
 */
public class XinYongPaiUtil {

    //贷款金额
    public static String getloan(String loan) {
        if (StrUtil.equals(BaseTypeInfoEnum.LoanAmount.la001.getValue(), loan)) {
            return "3";
        } else if (StrUtil.equals(BaseTypeInfoEnum.LoanAmount.la002.getValue(), loan)) {
            return "5";
        }else if (StrUtil.equals(BaseTypeInfoEnum.LoanAmount.la003.getValue(), loan)) {
            return "10";
        }else if (StrUtil.equals(BaseTypeInfoEnum.LoanAmount.la004.getValue(), loan)) {
            return "20";
        }
        return "50";

    }

    public static String getReqIp(String ip){
        if (StringUtils.isNotEmpty(ip)){
            return ip;
        }
        return "127.0.0.1";
    }


    //性别
    public static String getSex(Integer sex) {
        if (sex == 1) {
            return "0";
        }if (sex == 2) {
            return "1";
        }
        return "3";
    }

    //芝麻分
    public static String getZhimaScore(String zhima) {
        if (StrUtil.equals(BaseTypeInfoEnum.Zhima.zm001.getValue(), zhima)) {
            return "3";
        } else if (StrUtil.equals(BaseTypeInfoEnum.Zhima.zm002.getValue(), zhima)) {
            return "3";
        } else if (StrUtil.equals(BaseTypeInfoEnum.Zhima.zm003.getValue(), zhima)) {
            return "0";
        } else if (StrUtil.equals(BaseTypeInfoEnum.Zhima.zm004.getValue(), zhima)) {
            return "1";
        }
        return "2";
    }


    public static String getZiZhi(String house,String car,String baodan,String job,String gongjijin,String shebao,String xinyongka,String jdbaitiao,String yuqi){
        StringBuilder stringBuilder = new StringBuilder();
        if (StrUtil.equals(BaseTypeInfoEnum.House.hu002.getValue(), house) ||
            StrUtil.equals(BaseTypeInfoEnum.House.hu003.getValue(), house) ||
            StrUtil.equals(BaseTypeInfoEnum.House.hu004.getValue(), house)){
            stringBuilder.append("0,");
        }
        if (StrUtil.equals(BaseTypeInfoEnum.Car.car002.getValue(), car) ||
                StrUtil.equals(BaseTypeInfoEnum.Car.car003.getValue(), car)) {
            stringBuilder.append("1,");
        }
        if (StrUtil.equals(BaseTypeInfoEnum.Baoxian.bx002.getValue(), baodan) ||
                StrUtil.equals(BaseTypeInfoEnum.Baoxian.bx003.getValue(), baodan)) {
            stringBuilder.append("2,");
        }
        if (StrUtil.equals(BaseTypeInfoEnum.Gongzuo.gz001.getValue(), job)) {
            stringBuilder.append("3,");
        }
        if (StrUtil.equals(BaseTypeInfoEnum.Gongzuo.gz002.getValue(), job)) {
            stringBuilder.append("4,");
        }
        if (StrUtil.equals(BaseTypeInfoEnum.Gjj.gjj002.getValue(), gongjijin) ||
                StrUtil.equals(BaseTypeInfoEnum.Gjj.gjj003.getValue(), gongjijin)) {
            stringBuilder.append("5,");
        }
        if (StrUtil.equals(BaseTypeInfoEnum.Shebao.sb002.getValue(), shebao) ||
                StrUtil.equals(BaseTypeInfoEnum.Shebao.sb003.getValue(), shebao)) {
            stringBuilder.append("6,");
        }
        stringBuilder.append("7,");
        if (StrUtil.equals(BaseTypeInfoEnum.XinYongKa.xyk002.getValue(), xinyongka) ||
                StrUtil.equals(BaseTypeInfoEnum.XinYongKa.xyk003.getValue(), xinyongka) ||
                StrUtil.equals(BaseTypeInfoEnum.XinYongKa.xyk004.getValue(), xinyongka) ||
                StrUtil.equals(BaseTypeInfoEnum.XinYongKa.xyk005.getValue(), xinyongka)) {
            stringBuilder.append("11,");
        }
        if (StrUtil.equals(BaseTypeInfoEnum.Baitiao.bt002.getValue(), jdbaitiao) ||
                StrUtil.equals(BaseTypeInfoEnum.Baitiao.bt003.getValue(), jdbaitiao) ||
                StrUtil.equals(BaseTypeInfoEnum.Baitiao.bt004.getValue(), jdbaitiao) ||
                StrUtil.equals(BaseTypeInfoEnum.Baitiao.bt005.getValue(), jdbaitiao)) {
            stringBuilder.append("12,");
        }
        if (StrUtil.equals(BaseTypeInfoEnum.Yuqi.yq002.getValue(), yuqi) ||
                StrUtil.equals(BaseTypeInfoEnum.Yuqi.yq003.getValue(), yuqi) ||
                StrUtil.equals(BaseTypeInfoEnum.Yuqi.yq004.getValue(), yuqi) ||
                StrUtil.equals(BaseTypeInfoEnum.Yuqi.yq005.getValue(), yuqi)) {
            stringBuilder.append("13,");
        }
        stringBuilder.deleteCharAt(stringBuilder.length()-1);
        return stringBuilder.toString();
    }

}
